<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div class="father">
    <div class="son1">大儿子</div>
    <div class="son2">二儿子</div>
    <div>
      小儿子
      <p>孙子</p>
    </div>
  </div>

  <script>
    // 1. 查找父节点
    const son1 = document.querySelector('.son1')
    console.log(son1.parentNode);

    // 2. 查找子节点
    const father = document.querySelector('.father')
    console.log(father.children);

    // 3. 查找兄弟节点
    const son2 = document.querySelector('.son2')
    // 获取前一个节点
    console.log(son2.previousElementSibling);
    // 获取后一个节点
    console.log(son2.nextElementSibling);
  </script>
</body>

</html>